﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the GNU General Public License version 2 (GPLv2).
// See accompanying file License.txt or copy at http://phuse.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Phuse.Net.Nntp
{
    using System;

    /// <summary>Represents the response to a <see cref="DateCommand"/>.</summary>
    /// <threadsafety static="true" instance="false"/>
    public sealed class DateResponse : Response<DateResponse>
    {
        private readonly DateTime date;

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>Gets the current UTC date and time on the server.</summary>
        public DateTime Date
        {
            get { return this.date; }
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal DateResponse(long date)
        {
            int second = (int)(date % 100);
            date /= 100;
            int minute = (int)(date % 100);
            date /= 100;
            int hour = (int)(date % 100);
            date /= 100;
            int day = (int)(date % 100);
            date /= 100;
            int month = (int)(date % 100);
            int year = (int)(date / 100);

            this.date = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc);
        }
    }
}
